var xmlHttp;
var keyId=getCookie('userId');
var page=0;
var local="http://47.104.10.151";

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}
// 订单的id；
var keyid=new Array(6);
var totalPages;
//订单编号
var Order_code1;
var Order_code2;
var Order_code3;
var Order_code4;
var Order_code5;
var Order_code6;

function getInvite() {
    var kid=getCookie('userId');
    var url = local+":8080/login/displayCompany_Code";
    var xmlHttp = creatxmlHTTPInvite();
    var txt = "";//用于存储拼接字符串；
    //获取数据
    //拼接字符
    txt = "user_Id=" + kid;
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    function creatxmlHTTPInvite() {
        if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlHttp=new XMLHttpRequest();
        }else {
            // IE6, IE5 浏览器执行代码
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        return xmlHttp;
    }
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            document.getElementById("invite_code").value=json.msg;
        }
    }
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}

function onClickAjax_biding_decision_post() {
    function creatxmlHTTP_decision() {
        if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlHttp=new XMLHttpRequest();
        }else {
            // IE6, IE5 浏览器执行代码
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        return xmlHttp;
    }

    var xmlHttp = creatxmlHTTP_decision();
    var txt = "";//用于存储拼接字符串；
    var url=local+":8080/voteBid/findVoteBidByUserIdAndBidId";
    //拼接字符
    txt = "user_Id=" + keyId + "&page=" + page;
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);

    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            var result = xmlHttp.responseText;
            var json = eval("(" + result + ")");

            totalPages=json.data.totalPages;

            var input1 = document.getElementsByName("bid1");
            if (json.data.content[0].tax_status == 0) {
                input1[10].value = "无税率";
            } else if (json.data.content[0].tax_status == 1) {
                input1[10].value = "17%";
            }

            keyid[0] = json.data.content[0].keyId;
            Order_code1 = json.data.content[0].order_code;
            input1[0].value = json.data.content[0].company_code;
            input1[1].value = json.data.content[0].voteBid_code;
            input1[2].value = json.data.content[0].keyId;
            input1[3].value = json.data.content[0].product_name;
            input1[4].value = json.data.content[0].model;
            input1[5].value = json.data.content[0].size;
            input1[6].value = json.data.content[0].brand;
            input1[7].value = json.data.content[0].inventory;
            input1[8].value = json.data.content[0].sale_sigleprice.toFixed(2);
            input1[9].value = json.data.content[0].sale_amount.toFixed(2);
            input1[11].value = json.data.content[0].vote_company_code;
            input1[12].value = json.data.content[0].area;
            input1[13].value = json.data.content[0].deadline;
            input1[14].value = json.data.content[0].bid_status;


            var input2 = document.getElementsByName("bid2");
            if (json.data.content[1].tax_status == 0) {
                input2[10].value = "无税率";
            } else if (json.data.content[1].tax_status == 1) {
                input2[10].value = "17%";
            }

            keyid[1]= json.data.content[1].keyId;
            Order_code2 = json.data.content[1].order_code;
            input2[0].value = json.data.content[1].company_code;
            input2[1].value = json.data.content[1].voteBid_code;
            input2[2].value = json.data.content[1].keyId;
            input2[3].value = json.data.content[1].product_name;
            input2[4].value = json.data.content[1].model;
            input2[5].value = json.data.content[1].size;
            input2[6].value = json.data.content[1].brand;
            input2[7].value = json.data.content[1].inventory;
            input2[8].value = json.data.content[1].sale_sigleprice.toFixed(2);
            input2[9].value = json.data.content[1].sale_amount.toFixed(2);
            input2[11].value = json.data.content[1].vote_company_code;
            input2[12].value = json.data.content[1].area;
            input2[13].value = json.data.content[1].deadline;
            input2[14].value = json.data.content[1].bid_status;

            var input3 = document.getElementsByName("bid3");
            if (json.data.content[2].tax_status == 0) {
                input3[10].value = "无税率";
            } else if (json.data.content[2].tax_status == 1) {
                input3[10].value = "17%";
            }
            keyid[2]= json.data.content[2].keyId;
            Order_code3 = json.data.content[2].order_code;
            input3[0].value = json.data.content[2].company_code;
            input3[1].value = json.data.content[2].voteBid_code;
            input3[2].value = json.data.content[2].keyId;
            input3[3].value = json.data.content[2].product_name;
            input3[4].value = json.data.content[2].model;
            input3[5].value = json.data.content[2].size;
            input3[6].value = json.data.content[2].brand;
            input3[7].value = json.data.content[2].inventory;
            input3[8].value = json.data.content[2].sale_sigleprice.toFixed(2);
            input3[9].value = json.data.content[2].sale_amount.toFixed(2);
            input3[11].value = json.data.content[2].vote_company_code;
            input3[12].value = json.data.content[2].area;
            input3[13].value = json.data.content[2].deadline;
            input3[14].value = json.data.content[2].bid_status;



            var input4 = document.getElementsByName("bid4");
            if (json.data.content[3].tax_status == 0) {
                input4[10].value = "无税率";
            } else if (json.data.content[3].tax_status == 1) {
                input4[10].value = "17%";
            }
            keyid[3] = json.data.content[3].keyId;
            Order_code4 = json.data.content[3].order_code;
            input4[0].value = json.data.content[3].company_code;
            input4[1].value = json.data.content[3].voteBid_code;
            input4[2].value = json.data.content[3].keyId;
            input4[3].value = json.data.content[3].product_name;
            input4[4].value = json.data.content[3].model;
            input4[5].value = json.data.content[3].size;
            input4[6].value = json.data.content[3].brand;
            input4[7].value = json.data.content[3].inventory;
            input4[8].value = json.data.content[3].sale_sigleprice.toFixed(2);
            input4[9].value = json.data.content[3].sale_amount.toFixed(2);
            input4[11].value = json.data.content[3].vote_company_code;
            input4[12].value = json.data.content[3].area;
            input4[13].value = json.data.content[3].deadline;
            input4[14].value = json.data.content[3].bid_status;


            var input5= document.getElementsByName("bid5");
            if (json.data.content[0].tax_status == 0) {
                input5[10].value = "无税率";
            } else if (json.data.content[0].tax_status == 1) {
                input5[10].value = "17%";
            }
            keyid[4] = json.data.content[4].keyId;
            Order_code5 = json.data.content[4].order_code;
            input5[0].value = json.data.content[4].company_code;
            input5[1].value = json.data.content[4].voteBid_code;
            input5[2].value = json.data.content[4].keyId;
            input5[3].value = json.data.content[4].product_name;
            input5[4].value = json.data.content[4].model;
            input5[5].value = json.data.content[4].size;
            input5[6].value = json.data.content[4].brand;
            input5[7].value = json.data.content[4].inventory;
            input5[8].value = json.data.content[4].sale_sigleprice.toFixed(2);
            input5[9].value = json.data.content[4].sale_amount.toFixed(2);
            input5[11].value = json.data.content[4].vote_company_code;
            input5[12].value = json.data.content[4].area;
            input5[13].value = json.data.content[4].deadline;
            input5[14].value = json.data.content[4].bid_status;



            var input6 = document.getElementsByName("bid6");
            if (json.data.content[5].tax_status == 0) {
                input6[10].value = "无税率";
            } else if (json.data.content[5].tax_status == 1) {
                input6[10].value = "17%";
            }

            keyid[5] = json.data.content[5].keyId;
            Order_code6 = json.data.content[5].order_code;
            input6[0].value = json.data.content[5].company_code;
            input6[1].value = json.data.content[5].voteBid_code;
            input6[2].value = json.data.content[5].keyId;
            input6[3].value = json.data.content[5].product_name;
            input6[4].value = json.data.content[5].model;
            input6[5].value = json.data.content[5].size;
            input6[6].value = json.data.content[5].brand;
            input6[7].value = json.data.content[5].inventory;
            input6[8].value = json.data.content[5].sale_sigleprice.toFixed(2);
            input6[9].value = json.data.content[5].sale_amount.toFixed(2);
            input6[11].value = json.data.content[5].vote_company_code;
            input6[12].value = json.data.content[5].area;
            input6[13].value = json.data.content[5].deadline;
            input6[14].value = json.data.content[5].bid_status;


        }
    }
}
function creatxmlHTTP_cb() {
    if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlHttp=new XMLHttpRequest();
    }else {
        // IE6, IE5 浏览器执行代码
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlHttp;
}

function comfirmPro_bid1() {

    var xmlHttp = creatxmlHTTP_cb();
    //获取主页的用户
    var txt="";//拼接字符串；
    txt="order_id="+keyid[0];
    alert(keyid[0]);
    var url = local+":8080/voteBid/orderChangeTo3";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    alert("订单已收货");


}
function comfirmPro_bid2() {

    var xmlHttp = creatxmlHTTP_cb();
    //获取主页的用户
    var txt="";//拼接字符串；
    txt="order_id="+keyid[1];
    alert(keyid[1]);
    var url = local+":8080/voteBid/orderChangeTo3";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    alert("订单已收货");

}
function comfirmPro_bid3() {

    var xmlHttp = creatxmlHTTP_cb();
    //获取主页的用户
    var txt="";//拼接字符串；
    txt="order_id="+keyid[2];
    var url = local+":8080/voteBid/orderChangeTo3";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    alert("订单已收货");

}
function comfirmPro_bid4() {

    var xmlHttp = creatxmlHTTP_cb();
    //获取主页的用户
    var txt="";//拼接字符串；
    txt="order_id="+keyid[3];
    var url =local+":8080/voteBid/orderChangeTo3";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    alert("订单已收货");

}
function comfirmPro_bid5() {

    var xmlHttp = creatxmlHTTP_cb();
    //获取主页的用户
    var txt="";//拼接字符串；
    txt="order_id="+keyid[4];
    var url = local+":8080/voteBid/orderChangeTo3";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    alert("订单已收货");

}
function comfirmPro_bid6() {
    var xmlHttp = creatxmlHTTP_cb();
    //获取主页的用户
    var txt="";//拼接字符串；
    txt="order_id="+keyid[5];
    var url = local+":8080/voteBid/orderChangeTo3";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    alert("订单已收货");

}



function nextPage_bid_decision() {
    page++;
    if(totalPages>page){
        onClickAjax_biding_decision();
    }
    else alert("已经是最后一页");
}


function beforePage_bid_decision() {
    page--;
    if(page>=0){
        onClickAjax_biding_decision();
    }
    else alert("第一页");
}


